<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\index\controller;

/**
 * 前端首页控制器
 */
class Bussiness extends IndexBase
{
    
   /**
    * GMP符合与认证
    */
    public function bussinessGmp()
    {
        $this->bussinessCommon(1);
       
        return $this->fetch('bussiness_gmp');
    }
    
    
    /**
    * 国内注册
    */
    public function bussinessCfda()
    {
        
        $this->bussinessCommon(2);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('bussiness_cfda');
    }
    
    
    /**
    * GMP符合与认证
    */
    public function bussinessFda()
    {
        $this->bussinessCommon(3);
        
        return $this->fetch('bussiness_fda');
    }
    
    
    /**
    * MAH托管服务
    */
    public function bussinessMah()
    {
        $this->bussinessCommon(4);
        
        return $this->fetch('bussiness_mah');
    }
    
    
    /**
    * 药症事务顾问
    */
    public function bussinessDurg()
    {
        $this->bussinessCommon(5);
        
        return $this->fetch('bussiness_durg');
    }
    
    
    /**
    * 会议&培训
    */
    public function bussinessMeeting()
    {
        $this->bussinessCommon(6);
        
        return $this->fetch('bussiness_meeting');
    } 
    
    /**
     * 认证详情
     */
    public function gmpSecondary()
    {
        $this->busyCommon();
        
        if(array_key_exists('category_id', $this->param)){
            
            $where['category_id'] = $this->param['category_id'];
        }else{
            
            $where['id'] = $this->param['id'];
        }
        
        $info = $this->logicBussiness->getArticleInfo($where);
        
        $info['content'] = $info?html_entity_decode($info['content']):'';
        
        $this->assign('info',$info);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('bussiness_detail');
    }
    
    
    /**
     * 获取业务范围文章共用方法
     */
    public function bussinessCommon($pid)
    {
        $this->getAllColumn();
        
        $this->busyCommon();
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        //获取流程步骤内容
        $this->assign('info',$this->logicArticle->getStepInfo(["category_id"=>24]));
        
        $list = $this->logicBussiness->getBussinessCategory(array('pid'=>$pid),'id,name');
        
        $this->assign('count', count($list));
        
        foreach ($list as $k=>$v){
            
            $where['category_id'] = $v['id'];
            
            $list[$k]['tittle'] = $this->logicBussiness->getArticleList($where,'id,name');
 

        }

        $this->assign('list',$list);
    }
  
    
    /**
     * 文章详情
     */
    public function bussinessDetail()
    {
        $this->busyCommon();
        
        $this->assign('info',$this->logicBussiness->getBussinessInfo(['id'=> $this->param['id']],'name,content,id,updated_at'));
          
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('bussiness_detail');
    }
    
    
    /**
     * 更多业务文章
     */
    public function bussinessMore()
    {
        $this->busyCommon();
        
        $pid = array_key_exists('pid', $this->param)?$this->param['pid']:1;
        
        $list = $this->logicBussiness->getBussinessCategory(array('pid'=>$pid),'id,name');
        
        $this->assign('count', count($list));
        
        foreach ($list as $k=>$v){
            
            $where['category_id'] = $v['id'];
            
            $list[$k]['tittle'] = $this->logicBussiness->getArticleList($where,'id,name');
        }
        
        $this->assign('list', $list);
        
        //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('bussiness_more');
    }
    
    
    /**
     * 关于我们通用方法
     */
    public function busyCommon()
    {
        $this->assign('column_id',3);
    }
}
